// Code generated by bpf2go; DO NOT EDIT.
//go:build arm64

package tracer

import (
	"bytes"
	_ "embed"
	"fmt"
	"io"

	"github.com/cilium/ebpf"
)

type tcpdropEvent struct {
	Saddr       [16]uint8
	Daddr       [16]uint8
	Timestamp   uint64
	Af          uint16
	Dport       uint16
	Sport       uint16
	State       uint8
	Tcpflags    uint8
	Reason      uint32
	Netns       uint32
	ProcCurrent struct {
		MountNsId uint64
		Pid       uint32
		Tid       uint32
		Uid       uint32
		Gid       uint32
		Task      [16]uint8
	}
	ProcSocket struct {
		MountNsId uint64
		Pid       uint32
		Tid       uint32
		Uid       uint32
		Gid       uint32
		Task      [16]uint8
	}
	_ [8]byte
}

// loadTcpdrop returns the embedded CollectionSpec for tcpdrop.
func loadTcpdrop() (*ebpf.CollectionSpec, error) {
	reader := bytes.NewReader(_TcpdropBytes)
	spec, err := ebpf.LoadCollectionSpecFromReader(reader)
	if err != nil {
		return nil, fmt.Errorf("can't load tcpdrop: %w", err)
	}

	return spec, err
}

// loadTcpdropObjects loads tcpdrop and converts it into a struct.
//
// The following types are suitable as obj argument:
//
//	*tcpdropObjects
//	*tcpdropPrograms
//	*tcpdropMaps
//
// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
func loadTcpdropObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
	spec, err := loadTcpdrop()
	if err != nil {
		return err
	}

	return spec.LoadAndAssign(obj, opts)
}

// tcpdropSpecs contains maps and programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type tcpdropSpecs struct {
	tcpdropProgramSpecs
	tcpdropMapSpecs
}

// tcpdropSpecs contains programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type tcpdropProgramSpecs struct {
	IgTcpdrop *ebpf.ProgramSpec `ebpf:"ig_tcpdrop"`
}

// tcpdropMapSpecs contains maps before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type tcpdropMapSpecs struct {
	Events        *ebpf.MapSpec `ebpf:"events"`
	GadgetSockets *ebpf.MapSpec `ebpf:"gadget_sockets"`
}

// tcpdropObjects contains all objects after they have been loaded into the kernel.
//
// It can be passed to loadTcpdropObjects or ebpf.CollectionSpec.LoadAndAssign.
type tcpdropObjects struct {
	tcpdropPrograms
	tcpdropMaps
}

func (o *tcpdropObjects) Close() error {
	return _TcpdropClose(
		&o.tcpdropPrograms,
		&o.tcpdropMaps,
	)
}

// tcpdropMaps contains all maps after they have been loaded into the kernel.
//
// It can be passed to loadTcpdropObjects or ebpf.CollectionSpec.LoadAndAssign.
type tcpdropMaps struct {
	Events        *ebpf.Map `ebpf:"events"`
	GadgetSockets *ebpf.Map `ebpf:"gadget_sockets"`
}

func (m *tcpdropMaps) Close() error {
	return _TcpdropClose(
		m.Events,
		m.GadgetSockets,
	)
}

// tcpdropPrograms contains all programs after they have been loaded into the kernel.
//
// It can be passed to loadTcpdropObjects or ebpf.CollectionSpec.LoadAndAssign.
type tcpdropPrograms struct {
	IgTcpdrop *ebpf.Program `ebpf:"ig_tcpdrop"`
}

func (p *tcpdropPrograms) Close() error {
	return _TcpdropClose(
		p.IgTcpdrop,
	)
}

func _TcpdropClose(closers ...io.Closer) error {
	for _, closer := range closers {
		if err := closer.Close(); err != nil {
			return err
		}
	}
	return nil
}

// Do not access this directly.
//
//go:embed tcpdrop_bpfel_arm64.o
var _TcpdropBytes []byte
